home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / rsxwdk2s.zip / RSXWDK / LIBSRC / SYSDJ / DUP2.C < prev    next >
C/C++ Source or Header  |  1994-10-18  |  513b  |  26 lines

  1. /* dup2.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/doscalls.h>
  4. #include <io.h>
  5. #include <errno.h>
  6. #include "djio.h"
  7.  
  8. int dup2 (int handle1, int handle2)
  9. {
  10.     if (handle2 < 0)
  11.     {
  12.     errno = EINVAL;
  13.     return (-1);
  14.     }
  15.     if (handle2 >= _nfiles)
  16.     {
  17.     errno = EMFILE;
  18.     return (-1);
  19.     }
  20.     if (dos_dup2 (handle1, handle2) < 0)
  21.     return (-1);
  22.     _files[handle2] = _files[handle1];
  23.     _lookahead[handle2] = _lookahead[handle1];
  24.     return (handle2);
  25. }
  26.